﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccessLayer.DAL;
using DataAccessLayer;
using Common;
namespace BestBuy.AdminViews
{
    public partial class ListRegulation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = UserDAL.GetUserByUsername(HttpContext.Current.User.Identity.Name);
            if (user == null || user.RoleID != (int)RoleType.Admin)
            {
                Response.Redirect("~/Account/Login.aspx");
            }
            if (!IsPostBack)
            {
                LoadConfiguration();
            }
        }
        private void LoadConfiguration()
        {
            data.DataSource = ConfigurationDAL.GetAllConfiguration();
            data.DataBind();
        }
        protected void DeleteButtion_Click(object sender, EventArgs e)
        {
            
            Button senderButton = sender as Button;
            int id = Int32.Parse(senderButton.Attributes["ObjectId"]);
            //int ma = data.SelectedIndex;
            // Delete object here
            ConfigurationDAL.DeleteConfigurationID(id);
            LoadConfiguration();
        }
        protected void UpdateButtion_Click(object sender, EventArgs e)
        {

            // // Delete object here
           //// ConfigurationDAL.UpdateConfigurationID(id);
           // LoadConfiguration();
        }
    }
}